<template>
  <div class="_flex-y _p20 _flex-a-stretch">
    <div class="_cart _p5">
      <el-button type="primary" @click="openSync({})" size="small"
        >添加</el-button
      >
    </div>
    <div class="_flex _flex-wrap">
      <div
        class="_m-t-5"
        style="width: 180px"
        v-for="item in List"
        :key="item.id"
      >
        <div class="_cart _p5">
          <div class="_font-title _line">{{ item.name }}</div>
          <div>{{ $tool.dateStr(item.created_date) }}</div>
          <div class="_flex _m-t-5">
            <el-button type="primary" size="small" @click="openView(item)"
              >详情</el-button
            >
            <el-button type="warning" size="small" @click="openSync(item)"
              >编辑</el-button
            >
            <el-button type="danger" size="small" @click="del(item.id)"
              >删除</el-button
            >
          </div>
        </div>
      </div>
      <div style="width: 180px; height: 0" v-for="n in 10" :key="n"></div>
    </div>
    <ComDataUpdateDrawer
      ref="ComDataUpdateDrawer"
      code="function_app_info"
      :currentForm="sync"
      @syncClose="init"
    />
    <com-view :comData="sync"></com-view>
  </div>
</template>
<script>
import toolAction from "@/tool/http/tool-action";
import ComDataUpdateDrawer from "@/views/common/com-data-update-drawer.vue";
import ComView from "@/components/com-view/com-view.vue";

let funAppApi = toolAction.init("function_app_info");

export default {
  components: { ComDataUpdateDrawer, ComView },
  data() {
    return {
      List: [],
      sync: {},
      drawerView: false,
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    init() {
      funAppApi.list().then((res) => {
        this.List = res;
      });
    },
    openView(sync) {
      this.sync = {};
      this.$nextTick(() => {
        this.sync = sync;
        this.drawerView = true;
      });
    },
    openSync(sync) {
      this.sync = sync;
      this.$refs.ComDataUpdateDrawer.open();
    },
    del(id) {
      funAppApi.remove({ id }).then(() => {
        this.$element.msg();
        this.init();
      });
    },
  },
};
</script>
<style lang=""></style>
